package com.wwj.auction.login.controller;


import com.wwj.auction.common.result.R;
import com.wwj.auction.login.entity.GetOut;
import com.wwj.auction.login.service.GetOutService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 前端控制器
 * </p>
 *
 * @author wwj
 * @since 2022-01-02
 */
@RestController
@RequestMapping("/login/getOut")
@Api("商品评价")
public class GetOutController {


    @Autowired
    private GetOutService getOutService;

    /**
     * 发布所购商品的评价
     *
     * @param shopId
     * @param userId
     * @return
     */
    @GetMapping("/publish/{shopId}/{userId}/{memo}/{score}")
    public R publish(
            @PathVariable("shopId") Integer shopId,
            @PathVariable("userId") Integer userId,
            @PathVariable("memo") String memo,
            @PathVariable("score") String score
    ) {
        getOutService.publish(shopId, userId, memo, score);
        return R.ok();
    }

    /**
     * 检查用户是否已经对商品进行评价
     *
     * @param shopId
     * @param userId
     * @return
     */
    @GetMapping("/check/publish/{shopId}/{userId}")
    public R checkPublish(
            @PathVariable("shopId") Integer shopId,
            @PathVariable("userId") Integer userId
    ) {
        GetOut getOut = getOutService.checkPublish(shopId, userId);
        return R.ok().data("getOut", getOut);
    }
}

